package com.active.service.impl;

import com.active.bean.ActiveList;
import com.active.dao.ActiveListMapper;
import com.active.service.IActiveListService;
import com.base.dto.PageContent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class ActiveListServiceImpl implements IActiveListService {

    @Autowired
    private ActiveListMapper activeListDao;

    @Override
    @Transactional(readOnly = true)
    public PageContent<List<ActiveList>> getPage(PageContent<List<ActiveList>> page) throws Exception {
        page.setResultData(activeListDao.selectByParam(page.getParam()));
        return page;
    }

    @Override
    @Transactional(readOnly = true)
    public ActiveList getActiveListById(Integer id) throws Exception {
        return activeListDao.selectByPrimaryKey(id);
    }

    @Override
    public ActiveList getActiveListByUserAndId(Integer id,int userId) throws Exception {
        return activeListDao.selectByUserAndPrimaryKey(id,userId);
    }

    @Override
    @Transactional(readOnly = false)
    public int insertActiveList(ActiveList activeList) throws Exception {
        return activeListDao.insert(activeList);
    }

    @Override
    @Transactional(readOnly = false)
    public int deleteActiveListById(Integer id) throws Exception {
        return activeListDao.deleteByPrimaryKey(id);
    }

    @Override
    @Transactional(readOnly = false)
    public int updateActiveListById(ActiveList activeList) throws Exception{
        return activeListDao.updateByPrimaryKey(activeList);
    }

    @Override
    @Transactional(readOnly = false)
    public int updateActiveListSelectiveById(ActiveList activeList) throws Exception{
        return activeListDao.updateByPrimaryKeySelective(activeList);
    }
}
